package lab3;


import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;

public class CountWordsThread implements Runnable {

	String lines[];
	ConcurrentHashMap<String, AtomicInteger> Words = new ConcurrentHashMap<String, AtomicInteger>();

	public CountWordsThread(String lines[], ConcurrentHashMap<String, AtomicInteger> words2) {
		this.lines = lines;
		this.Words = words2;
	}

	@Override
	public void run() {
			String s[];
			for (int i = 0; i < lines.length; i++) {
				if (lines[i] != null) {
					s = lines[i].split("[\\p{Punct}\\s]");
					for (int j = 0; j < s.length; j++) {
						Words.putIfAbsent(s[j],new AtomicInteger(0));
						Words.get(s[j]).incrementAndGet();
							

						}
					}
				}
			}


	}
